package 笔试.A2022拼多多;

import java.util.PriorityQueue;
import java.util.Scanner;

public class first {
    
    public static void main(String arg[]){//main--来自高金磊
         Scanner scanner=new Scanner(System.in);
         int n=scanner.nextInt();
        PriorityQueue<Long> data1=new PriorityQueue<>();
        PriorityQueue<Long> data2=new PriorityQueue<>();
        for (int i = 0; i < n; i++) {
            data1.add(scanner.nextLong());
        }
        long res=0L;
        for (int i = 0; i < n; i++) {
            data2.add(scanner.nextLong());
        }
        for (int i = 0; i < n; i++) {
            res+=(data1.peek()-data2.peek())*(data1.poll()-data2.poll());
        }
        System.out.println(res);
    }
}
